package org.hdl.anima.message;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author qiuhd
 * @since  2014年8月15日
 */
public class ResponseObjWrap{
	
	private MessageHeader header;
	private Receivers receivers;
	private IMessage msg;
	
	public ResponseObjWrap(IMessage resp) {
		this.msg = resp; 
	}
	
	public ResponseObjWrap(IMessage resp,int receiver) {
		this.msg = resp;
		List<Integer> list = new ArrayList<Integer>(1);
		list.add(receiver);
		this.receivers = new Receivers(list);
	}
	
	public ResponseObjWrap(IMessage resp,List<Integer> receivers) {
		this.msg = resp; 
		this.receivers = new Receivers(receivers);
	}
	
	public ResponseObjWrap(MessageHeader header,IMessage resp,Receivers receivers) {
		this.header = header;
		this.msg = resp; 
		this.receivers = receivers;
	}
	
//	@Override
//	public void serialize(OutputArchive archive) throws IOException {
//		archive.startVector(receviers);
//		if (receviers != null) {
//			for (int receiver : receviers) {
//				archive.writeInt(receiver);
//			}
//		}
//		archive.writeRecord(msg);
//	}
	

//	@Override
//	public void deserialize(InputArchive archive) throws IOException {
//		Index id = archive.startVector();
//		if (id != null) {
//			receviers = new ArrayList<Integer>(id.size());
//			if (!id.done()) {
//				int r = archive.readInt();
//				receviers.add(r);
//				id.incr();
//			}
//		}
//		archive.readRecord(msg);
//	}

//	public List<Integer> getReceviers() {
//		return receviers;
//	}
//
//	public void setReceviers(List<Integer> receviers) {
//		this.receviers = receviers;
//	}
	
	public IMessage getContent() {
		return msg;
	}

	public MessageHeader getHeader() {
		return header;
	}

	public void setHeader(MessageHeader header) {
		this.header = header;
	}

	public Receivers getReceivers() {
		return receivers;
	}

	public void setReceivers(Receivers receivers) {
		this.receivers = receivers;
	}

	public void setMsg(IMessage msg) {
		this.msg = msg;
	}
}

